using System;
using System.Collections.Generic;
using System.Text;

namespace StateMachine_Graphical_Editor.Utils
{
    /// <summary>
    /// Represents a data structure of a GTransition's complex name.
    /// <para>Used to display multiple transitions' names by a single
    /// <para>GTransition representation.</para></para>
    /// </summary>
    public class MultipleNames
    {
        #region Members:

        private List<string> names;

        #region Constants:

        private static string SINGLE_ITEM_TITLE = "Transition:";
        private static string MULTIPLE_ITEMS_TITLE = "Transitions:";

        #endregion

        #endregion

        #region C'tors:

        public MultipleNames()
        {
            names = new List<string>();
        }

        public MultipleNames(string primeName)
            : this()
        {
            names.Add(primeName);
        }

        #endregion

        #region Getters:

        public List<string> NamesList
        {
            get { return names; }
        }

        public int NumOfTrans
        {
            get { return names.Count; }
        }

        #endregion

        #region Methods:

        public void addName(string name)
        {
            names.Add(name);
        }

        public bool removeName(string name)
        {
            return names.Remove(name); 
        }

        public string getDisplayNames()
        {
            StringBuilder result = new StringBuilder();
            result.Append( (names.Count == 1) ? SINGLE_ITEM_TITLE : MULTIPLE_ITEMS_TITLE );

            foreach (string name in names)
            {
                result.Append("\n" + name);
            }
            return result.ToString();
        }

        /// <summary>
        /// Provides the string representation of all names stored.
        /// </summary>
        /// <returns>The GTransition's names</returns>
        public override string ToString()
        {
            return getDisplayNames();
        }

        #endregion

    }
}
